<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link type="text/css" rel="stylesheet" href="css/style.css" />
    <!--[if IE 6]>
    <script src="js/iepng.js" type="text/javascript"></script>
        <script type="text/javascript">
           EvPNG.fix('div, ul, img, li, input, a'); 
        </script>
    <![endif]-->
        
    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="js/menu.js"></script>    
        
	<script type="text/javascript" src="js/select.js"></script>
    <script type="text/javascript" src="js/distpicker.min.js"></script>
    
<title>地址管理</title>
</head>
<body>  
<jsp:include page="top2.jsp" />
<div class="i_bg bg_color">
    <!--Begin 用户中心 Begin -->
	<div class="m_content">
   		<div class="m_left">
        	<div class="left_n">管理中心</div>
            <div class="left_m">
            	<div class="left_m_t t_bg1">订单中心</div>
                <ul>
                	<li><a href="BaseOrderServlet?method=findOrderByUserId">我的订单</a></li>
                    <li><a href="AddressServlet?method=findAll" class="now">收货地址</a></li>
                    <li><a href="#">缺货登记</a></li>
                    <li><a href="#">跟踪订单</a></li>
                </ul>
            </div>
            <div class="left_m">
            	<div class="left_m_t t_bg2">会员中心</div>
                <ul>
                	<li><a href="member_user.jsp">用户信息</a></li>
                    <li><a href="Member_Collect.html">我的收藏</a></li>
                    <li><a href="Member_Msg.html">我的留言</a></li>
                    <li><a href="Member_Links.html">推广链接</a></li>
                    <li><a href="#">我的评论</a></li>
                </ul>
            </div>
            <div class="left_m">
            	<div class="left_m_t t_bg3">账户中心</div>
                <ul>
                	<li><a href="member_safe.jsp">账户安全</a></li>
                    <li><a href="Member_Packet.html">我的红包</a></li>
                    <li><a href="Member_Money.html">资金管理</a></li>
                </ul>
            </div>
            <div class="left_m">
            	<div class="left_m_t t_bg4">分销中心</div>
                <ul>
                	<li><a href="Member_Member.html">我的会员</a></li>
                    <li><a href="Member_Results.html">我的业绩</a></li>
                    <li><a href="Member_Commission.html">我的佣金</a></li>
                    <li><a href="Member_Cash.html">申请提现</a></li>
                </ul>
            </div>
        </div>
		<div class="m_right">
            <p></p>
            <div class="mem_tit">收货地址</div>
            <c:forEach items="${AddressList}" var="address">
            	<div class="address" 
	            	<c:if test="${address.isDefault>0 }">
	            		style="background-color: lightyellow"
	            	</c:if>
				>
	            	<div class="a_close"><a href="AddressServlet?method=del&id=${address.id }"><img src="images/a_close.png" /></a></div>
	            	<table border="0" class="add_t" align="center" style="width:98%; margin:10px auto;" cellspacing="0" cellpadding="0">
	                  <tr>
	                    <td colspan="2" style="font-size:14px; color:#ff4e00;">${address.remark }
	                    	<c:if test="${address.isDefault>0 }">(默认)</c:if>
	                    </td>
	                  </tr>
	                  <tr>
	                    <td align="right" width="80">收货人姓名：</td>
	                    <td>${address.receiver }</td>
	                  </tr>
	                  <tr>
	                    <td align="right">配送区域：</td>
	                    <td>${address.province }${address.city }${address.district }</td>
	                  </tr>
	                  <tr>
	                    <td align="right">详细地址：</td>
	                    <td>${address.province }${address.city }${address.district }${address.address }</td>
	                  </tr>
	                  <tr>
	                    <td align="right">手机：</td>
	                    <td>${address.phone }</td>
	                  </tr>
	                  <tr>
	                    <td align="right">电话：</td>
	                    <td>028-12345678</td>
	                  </tr>
	                  <tr>
	                    <td align="right">电子邮箱：</td>
	                    <td>${address.email }</td>
	                  </tr>
	                  <tr>
	                    <td align="right">标志建筑：</td>
	                    <td>世外桃源</td>
	                  </tr>
	                </table>
					
	                <p align="right">
	                	<c:if test="${address.isDefault==0 }">
	                		<a href="AddressServlet?method=setDefault&id=${address.id }" style="color:#ff4e00;">设为默认</a>
	                	</c:if>
	                	&nbsp; &nbsp; &nbsp; &nbsp; <a onclick="showEdit(${address.id})" style="color:#ff4e00;">编辑</a>&nbsp; &nbsp; &nbsp; &nbsp; 
	                	<a href="AddressServlet?method=change&id=${address.id }" style="color:#ff4e00;">选择地址</a>&nbsp; &nbsp; &nbsp; &nbsp;
	                </p>
	
	            </div>
			</c:forEach>
            <div class="mem_tit">
            	<a onclick="showAdd()"><img src="images/add_ad.gif" /></a>
            </div>
            <!-- 添加地址 -->
            <form id="add" style="display: none" action="AddressServlet">
            <input type="hidden" name="method" value="add" />
            <table border="0" class="add_tab" style="width:930px;"  cellspacing="0" cellpadding="0">
              <tr>
                <td width="135" align="right">配送地区</td>
                <td colspan="3" style="font-family:'宋体';">
				<div data-toggle="distpicker">
				  <select id="province" name="province" data-province="---- 选择省份 ----"></select>
				  <select id="city" name="city" data-city="---- 选择城市 ----"></select>
				  <select id="district" name="district" data-district="---- 选择区县 ----"></select>
				  （必填）
				</div>
                </td>
              </tr>
              <tr>
                <td align="right">收货人姓名</td>
                <td style="font-family:'宋体';"><input type="text" name="receiver" value="姓名" class="add_ipt" />（必填）</td>
                <td align="right">电子邮箱</td>
                <td style="font-family:'宋体';"><input type="text" name="email" value="12345678@qq.com" class="add_ipt" />（必填）</td>
              </tr>
              <tr>
                <td align="right">详细地址</td>
                <td style="font-family:'宋体';"><input type="text" name="address" value="世外桃源" class="add_ipt" />（必填）</td>
                <td align="right">邮政编码</td>
                <td style="font-family:'宋体';"><input type="text" name="part" value="610000" class="add_ipt" /></td>
              </tr>
              <tr>
                <td align="right">手机</td>
                <td style="font-family:'宋体';"><input type="text" name="phone" value="1361234587" class="add_ipt" />（必填）</td>
                <td align="right">电话</td>
                <td style="font-family:'宋体';"><input type="text" name="phone" value="028-12345678" class="add_ipt" /></td>
              </tr>
              <tr>
                <td align="right">备注</td>
                <td style="font-family:'宋体';"><input type="text" name="remark" value="世外桃源大酒店" class="add_ipt" /></td>
                <td align="right">最佳送货时间</td>
                <td style="font-family:'宋体';"><input type="text" name="receiveTime" value="" class="add_ipt" /></td>
              </tr>
            </table>
           	<p align="right">
            	<a onclick="jq('#add').submit()" class="add_b">确认添加</a>
            </p> 
           </form>
           <!-- 添加地址End -->
           
            <!-- 修改地址 -->
            <form id="edit" style="display: none" action="AddressServlet">
            <input type="hidden" name="method" value="edit" />
            <input type="hidden" id="id" name="id" />
            <table border="0" class="add_tab" style="width:930px;"  cellspacing="0" cellpadding="0">
              <tr>
                <td width="135" align="right">配送地区</td>
                <td colspan="3" style="font-family:'宋体';">
				<div data-toggle="distpicker">
				  <select id="edit_province" name="province" data-province="---- 选择省份 ----"></select>
				  <select id="edit_city" name="city" data-city="---- 选择城市 ----"></select>
				  <select id="edit_district" name="district" data-district="---- 选择区县 ----"></select>
				  （必填）
				</div>
                </td>
              </tr>
              <tr>
                <td align="right">收货人姓名</td>
                <td style="font-family:'宋体';"><input type="text" name="receiver" value="姓名" class="add_ipt" />（必填）</td>
                <td align="right">电子邮箱</td>
                <td style="font-family:'宋体';"><input type="text" name="email" value="12345678@qq.com" class="add_ipt" />（必填）</td>
              </tr>
              <tr>
                <td align="right">详细地址</td>
                <td style="font-family:'宋体';"><input type="text" name="address" value="世外桃源" class="add_ipt" />（必填）</td>
                <td align="right">邮政编码</td>
                <td style="font-family:'宋体';"><input type="text" name="part" value="610000" class="add_ipt" /></td>
              </tr>
              <tr>
                <td align="right">手机</td>
                <td style="font-family:'宋体';"><input type="text" name="phone" value="1361234587" class="add_ipt" />（必填）</td>
                <td align="right">电话</td>
                <td style="font-family:'宋体';"><input type="text" name="phone" value="028-12345678" class="add_ipt" /></td>
              </tr>
              <tr>
                <td align="right">备注</td>
                <td style="font-family:'宋体';"><input type="text" name="remark" value="世外桃源大酒店" class="add_ipt" /></td>
                <td align="right">最佳送货时间</td>
                <td style="font-family:'宋体';"><input type="text" name="receiveTime" value="" class="add_ipt" /></td>
              </tr>
            </table>
           	<p align="right">
            	<a onclick="jq('#edit').submit()" class="add_b">确认修改</a>
            </p> 
           </form>
           <!-- 修改地址End -->

            
        </div>
    </div>
	<!--End 用户中心 End--> 
    <!--Begin Footer Begin -->
    <div class="b_btm_bg b_btm_c">
        <div class="b_btm">
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="images/b1.png" width="62" height="62" /></td>
                <td><h2>正品保障</h2>正品行货  放心购买</td>
              </tr>
            </table>
			<table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="images/b2.png" width="62" height="62" /></td>
                <td><h2>满38包邮</h2>满38包邮 免运费</td>
              </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="images/b3.png" width="62" height="62" /></td>
                <td><h2>天天低价</h2>天天低价 畅选无忧</td>
              </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;" cellspacing="0" cellpadding="0">
              <tr>
                <td width="72"><img src="images/b4.png" width="62" height="62" /></td>
                <td><h2>准时送达</h2>收货时间由你做主</td>
              </tr>
            </table>
        </div>
    </div>
    <div class="b_nav">
    	<dl>                                                                                            
        	<dt><a href="#">新手上路</a></dt>
            <dd><a href="#">售后流程</a></dd>
            <dd><a href="#">购物流程</a></dd>
            <dd><a href="#">订购方式</a></dd>
            <dd><a href="#">隐私声明</a></dd>
            <dd><a href="#">推荐分享说明</a></dd>
        </dl>
        <dl>
        	<dt><a href="#">配送与支付</a></dt>
            <dd><a href="#">货到付款区域</a></dd>
            <dd><a href="#">配送支付查询</a></dd>
            <dd><a href="#">支付方式说明</a></dd>
        </dl>
        <dl>
        	<dt><a href="#">会员中心</a></dt>
            <dd><a href="#">资金管理</a></dd>
            <dd><a href="#">我的收藏</a></dd>
            <dd><a href="#">我的订单</a></dd>
        </dl>
        <dl>
        	<dt><a href="#">服务保证</a></dt>
            <dd><a href="#">退换货原则</a></dd>
            <dd><a href="#">售后服务保证</a></dd>
            <dd><a href="#">产品质量保证</a></dd>
        </dl>
        <dl>
        	<dt><a href="#">联系我们</a></dt>
            <dd><a href="#">网站故障报告</a></dd>
            <dd><a href="#">购物咨询</a></dd>
            <dd><a href="#">投诉与建议</a></dd>
        </dl>
        <div class="b_tel_bg">
        	<a href="#" class="b_sh1">新浪微博</a>            
        	<a href="#" class="b_sh2">腾讯微博</a>
            <p>
            服务热线：<br />
            <span>400-123-4567</span>
            </p>
        </div>
        <div class="b_er">
            <div class="b_er_c"><img src="images/er.gif" width="118" height="118" /></div>
            <img src="images/ss.png" />
        </div>
    </div>    
    <div class="btmbg">
		<div class="btm">
        	备案/许可证编号：蜀ICP备12009302号-1-www.dingguagua.com   Copyright © 2015-2018 尤洪商城网 All Rights Reserved. 复制必究 , Technical Support: Dgg Group <br />
            <img src="images/b_1.gif" width="98" height="33" /><img src="images/b_2.gif" width="98" height="33" /><img src="images/b_3.gif" width="98" height="33" /><img src="images/b_4.gif" width="98" height="33" /><img src="images/b_5.gif" width="98" height="33" /><img src="images/b_6.gif" width="98" height="33" />
        </div>    	
    </div>
    <!--End Footer End -->    
</div>

</body>


<script>
function showAdd(){
	jq("#add").css('display',"block");
	jq("#edit").css('display',"none");
}

function showEdit(id){
	jq.get(
		'AddressServlet?method=findById',
		{
			id:id
		},function(res){
			//console.log(res)
			jq.each(res, function(key, value) {
			  var $element = jq('#edit input[name="' + key + '"]');
			  $element.val(value);
			});
			jq("#edit_province").find('option[data-text="'+res.province+'"]').attr("selected","selected").trigger('change')
 			jq("#edit_city").find('option[data-text="'+res.city+'"]').attr("selected","selected").trigger('change')
			jq("#edit_district").find('option[data-text="'+res.district+'"]').attr("selected","selected").trigger('change')
		},'json'
	)
	jq("#edit").css('display',"block");
	jq("#add").css('display',"none");
}

</script>
</html>

